package com.ruoyi.web.controller.scanCodeLogin;

import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.web.service.IScanCodeService;
import io.swagger.v3.oas.annotations.Operation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@Slf4j
@RestController
@RequiredArgsConstructor
@RequestMapping("/scan-code-login")
public class ScanCodeLoginController {
    @Resource
    private IScanCodeService scanCodeService;

    //接口负载均衡
    @Operation(summary = "获取登录二维码")
    @GetMapping("/getLoginCode/{t}")
    public AjaxResult getAll(@PathVariable("t") String t) {
        return scanCodeService.getAll(t);
    }

    // 检查登录状态
    @GetMapping("/status")
//    @IgnoreInterceptor(dataPermission = true, tenant = true)
    @Transactional(rollbackFor = Exception.class)
    public AjaxResult checkLoginStatus(@RequestParam String token) {

        return scanCodeService.checkLoginStatus(token);
    }
}
